package com.itawei.d3_TCP;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {
    public static void main(String[] args) throws IOException {
        //TCP接收数据
        //1.创建一个服务器Socket对象
        ServerSocket ss = new ServerSocket(10086);
        //2.监听客户端 获取客户端Socket对象
        Socket socket = ss.accept();
        //3.获取输入流，接收数据
        InputStream is = socket.getInputStream();
        //4.读取数据
        InputStreamReader isr = new InputStreamReader(is);
        BufferedReader br = new BufferedReader(isr);
        int b;
        while((b = br.read()) != -1){
            System.out.println((char)b);
        }
        //5.释放资源
        is.close();
        socket.close();


    }
}
